package shutdownhook;

public class Demo1 {
    public void start() {
        System.out.println("Demo");
        Runtime.getRuntime().addShutdownHook(new ShundownHook());
    }
    public static void main(String[] args) {
        Demo1 demo1 = new Demo1();
        demo1.start();
        try {
            System.in.read();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

class ShundownHook extends Thread {
    @Override
    public void run() {
        System.out.println("Shutting down");
    }
}